#include <jni.h>
#include <string>

extern "C"
JNIEXPORT void JNICALL
Java_com_itfitness_arraycopy_MainActivity_arrayCopy(JNIEnv *env, jobject instance, jobject arraySrc,
                                                    jint srcPos, jobject arraDst, jint dstPos,
                                                    jint copyLength) {
    //1.先将源数组和目标数组转换成jobjectArray
    jobjectArray src_arr = reinterpret_cast<jobjectArray>(arraySrc);
    jobjectArray src_dst = reinterpret_cast<jobjectArray>(arraDst);

    //2.通过循环将源数组的值赋给目标数组
    for(int i = srcPos ; i < srcPos + copyLength ; i ++){
        jobject element = env->GetObjectArrayElement(src_arr,i);
        env->SetObjectArrayElement(src_dst,dstPos,element);
        dstPos++;
    }
}